結果
問題 | No.1097 Remainder Operation |
ユーザー | i_am_nicolen_22 |
提出日時 | 2020-06-27 01:08:28 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 202 ms / 2,000 ms |
コード長 | 2,781 bytes |
コンパイル時間 | 2,713 ms |
コンパイル使用メモリ | 177,788 KB |
実行使用メモリ | 13,316 KB |
最終ジャッジ日時 | 2024-07-05 04:34:43 |
合計ジャッジ時間 | 5,727 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 2 ms
6,816 KB |
testcase_02 | AC | 2 ms
6,940 KB |
testcase_03 | AC | 2 ms
6,940 KB |
testcase_04 | AC | 2 ms
6,940 KB |
testcase_05 | AC | 2 ms
6,940 KB |
testcase_06 | AC | 2 ms
6,940 KB |
testcase_07 | AC | 17 ms
6,940 KB |
testcase_08 | AC | 17 ms
6,944 KB |
testcase_09 | AC | 18 ms
6,944 KB |
testcase_10 | AC | 17 ms
6,940 KB |
testcase_11 | AC | 18 ms
6,940 KB |
testcase_12 | AC | 160 ms
6,940 KB |
testcase_13 | AC | 154 ms
6,940 KB |
testcase_14 | AC | 156 ms
6,944 KB |
testcase_15 | AC | 157 ms
6,944 KB |
testcase_16 | AC | 158 ms
6,940 KB |
testcase_17 | AC | 158 ms
6,944 KB |
testcase_18 | AC | 199 ms
13,316 KB |
testcase_19 | AC | 201 ms
11,904 KB |
testcase_20 | AC | 201 ms
11,904 KB |
testcase_21 | AC | 202 ms
12,796 KB |
testcase_22 | AC | 201 ms
12,756 KB |
コンパイルメッセージ
main.cpp: In function 'int main()': main.cpp:71:27: warning: 'id' may be used uninitialized [-Wmaybe-uninitialized] 71 | cnt=qq[id+i]-qq[id]; | ^ main.cpp:58:9: note: 'id' was declared here 58 | int id; | ^~ main.cpp:66:9: warning: 'idx' may be used uninitialized [-Wmaybe-uninitialized] 66 | int syuki=idx-id; | ^~~~~ main.cpp:42:9: note: 'idx' was declared here 42 | int idx; | ^~~ main.cpp:61:9: warning: 'c' may be used uninitialized [-Wmaybe-uninitialized] 61 | if(r[i]==c){ | ^~ main.cpp:41:9: note: 'c' was declared here 41 | int c; | ^
ソースコード
#include <bits/stdc++.h> using namespace std; #define REP(i, s) for (int i = 0; i < s; ++i) #define ALL(v) (v).begin(), (v).end() #define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl #define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i) #define DEBUG #define int long long #define INF 1e18 template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) { return s << '<' << P.first << ", " << P.second << '>'; } template<class T> ostream& operator << (ostream &s, vector<T> P) { for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; } template<class T> ostream& operator << (ostream &s, vector<vector<T> > P) { for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; } template<class T> ostream& operator << (ostream &s, set<T> P) { EACH(it, P) { s << "<" << *it << "> "; } return s << endl; } template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) { EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; } template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";} typedef long long ll; signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin>>n; vector<int>a(n); for (int i = 0; i < n; i++) { cin>>a[i]; } int cnt=0; vector<int>r,qq; map<int,int>mp; int c; int idx; for (int i = 0; i <= n; i++) { int s=cnt%n; if(mp[s]!=0){ c=s; idx=i; qq.push_back(cnt); r.push_back(s); break; } qq.push_back(cnt); mp[s]++; r.push_back(s); cnt+=a[s]; } int id; for (int i = 0; i < n; i++) { if(r[i]==c){ id=i; break; } } int syuki=idx-id; vector<int>b; cnt=0; for (int i = 0; i <= syuki; i++) { cnt=qq[id+i]-qq[id]; b.push_back(cnt); } // show(qq); //show(r); //show(b); //cerr<<" syuki"<<syuki<<endl; int q; cin>>q; for (int i = 0; i < q; i++) { int k; cin>>k; if(k<qq.size()){ cout<<qq[k]<<endl; } else{ int ans=qq[id]; k-=id; int d=k/syuki; ans+=b.back()*d; ans+=b[k%syuki]; //cerr<<b.back()<<" "<<d<<" "<<k<<endl; cout<<ans<<endl; } } // cerr<<(ll)455580*(271828/2)<<endl; return 0; }