TLE on 16 求调
查看原帖
TLE on 16 求调
1211668
WMY_楼主2025/8/30 17:31
#include <bits/stdc++.h>
using namespace std;

using i64 = long long;
using u64 = unsigned long long;

namespace I {

char buf[1048576];
int p, end;

int gc() {
    if (p == end) {
        end = fread(buf, 1, 1048576, stdin);
        p = 0;
    }
    return p == end ? EOF : buf[p++];
}

template <class T, enable_if_t<is_integral<T>::value, int> = 0>
bool read(T& x) {
    int c = gc(), sgn = 1;
    while (c != EOF && !isdigit(c)) {
        if (c == '-') sgn = -1;
        c = gc();
    }
    if (c == EOF) return false;
    x = 0;
    while (isdigit(c)) {
        x = x * 10 + (c ^ 48);
        c = gc();
    }
    x *= sgn;
    return true;
}

// template <class T, enable_if_t<is_floating_point<T>::value, int> = 0>
// bool read(T& x) {
//     int c = gc(), sgn = 1;
//     while (!isspace(c)) c = gc();
//     if (c == EOF) return false;
    
//     return true;
// }

bool read(string& s) {
    s.clear();
    int c = gc();
    while (isspace(c)) c = gc();
    if (c == EOF) return false;
    while (c != EOF && !isspace(c)) s.push_back(c);
    return true;
}

}

int main() {
    int n;
    I::read(n);
    i64 sum = 0;
    while (n--) {
        int x;
        I::read(x);
        sum += x;
    }
    printf("%lld\n", sum);
}
2025/8/30 17:31
加载中...